package com.meilingcloud.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meilingcloud.system.domain.SysAttach;
import com.meilingcloud.system.mapper.SysAttachMapper;
import com.meilingcloud.system.service.ISysAttachService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 附件 Service业务层处理
 *
 * @author chenl
 * @date 2021-03-15
 */
@Service
public class SysAttachServiceImpl extends ServiceImpl<SysAttachMapper, SysAttach> implements ISysAttachService {

    @Override
    public List<SysAttach> queryList(SysAttach sysAttach) {
        LambdaQueryWrapper<SysAttach> lqw = Wrappers.lambdaQuery();
        if (sysAttach.getAttachId() != null) {
            lqw.eq(SysAttach::getAttachId, sysAttach.getAttachId());
        }
        if (sysAttach.getRelateId() != null) {
            lqw.eq(SysAttach::getRelateId, sysAttach.getRelateId());
        }
        if (StringUtils.isNotBlank(sysAttach.getModule())) {
            lqw.eq(SysAttach::getModule, sysAttach.getModule());
        }
        if (StringUtils.isNotBlank(sysAttach.getFileName())) {
            lqw.like(SysAttach::getFileName, sysAttach.getFileName());
        }
        if (StringUtils.isNotBlank(sysAttach.getFileUrl())) {
            lqw.eq(SysAttach::getFileUrl, sysAttach.getFileUrl());
        }
        if (StringUtils.isNotBlank(sysAttach.getFileExt())) {
            lqw.eq(SysAttach::getFileExt, sysAttach.getFileExt());
        }
        if (sysAttach.getFileSize() != null) {
            lqw.eq(SysAttach::getFileSize, sysAttach.getFileSize());
        }
        return this.list(lqw);
    }
}
